#! /bin/sh
### BEGIN INIT INFO
# Provides:          npd6
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
### END INIT INFO

# Author: Sean Groarke, sgroarke@gmail.com>
# $HeadURL: http://npd6.googlecode.com/svn/tags/0.4.2/etc/npd6 $
# $Id: npd6 51 2011-08-03 11:14:38Z npd6Project $

# Do NOT "set -e"

PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
DESC="npd6 - Neighbor proxy Daemon IPv6"
NAME=npd6
DAEMON=/usr/local/bin/$NAME
DAEMON_ARGS="--debug"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

do_reload() {
	#
	# If the daemon can reload its configuration without
	# restarting (for example, when it is sent a SIGHUP),
	# then implement that here.
	#
	log_daemon_msg "Doing a daemon reload - USR1"
	start-stop-daemon --stop --signal USR1 --quiet --pidfile $PIDFILE --name $NAME
	return 0
}

case "$1" in
  start)
	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
	#do_start
	start-stop-daemon --start --exec $DAEMON -- $DAEMON_ARGS
	case "$?" in
		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	esac
	;;
  stop)
	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
	#do_stop
	start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --name $NAME
	case "$?" in
		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	esac
	;;
  status)
       status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
       ;;
  #reload|force-reload)
	#
	# If do_reload() is not implemented then leave this commented out
	# and leave 'force-reload' as an alias for 'restart'.
	#
	#log_daemon_msg "Reloading $DESC" "$NAME"
	#do_reload
	#log_end_msg $?
	#;;
  restart)
	log_daemon_msg "Restarting $DESC" "$NAME"
        start-stop-daemon --stop --retry=TERM/30/KILL/5 --exec $DAEMON
        start-stop-daemon --start --exec $DAEMON -- $DAEMON_ARGS 
	;;
  *)
	echo "Usage: $SCRIPTNAME {start|stop|status|restart}" >&2
	exit 3
	;;
esac

:
